#include <cstdio>
#include <vector>
#include <array>


/**
 * 无向带权图的邻接表
 * 
 * */
int main() {

    std::vector<std::vector<std::array<int, 2>>> graph(6, std::vector<std::array<int, 2>>());

    int edges[5][3] = {
        {1, 2, 3},
        // 2-3,权重为5
        {2, 3, 5},
        // 3-5,权重为1
        {3, 5, 1},
        // 4-5,权重为8
        {4, 5, 8},
        // 5-1,权重为6
        {5, 1, 6}
    };

    for (int i = 0; i < 5; i++) {
        graph[edges[i][0]].push_back({ edges[i][1], edges[i][2] });
        graph[edges[i][1]].push_back({ edges[i][0], edges[i][2] });
    }

    printf("无向带权图的邻接表遍历:\n");

    for (int i = 0; i < graph.size(); i++) {
        printf("%d -> ", i);
        for (int j = 0; j < graph[i].size(); j++) {
            printf("%d(%d) ", graph[i][j][0], graph[i][j][1]);
        }
        printf("\n");
    }

	return 0;

}